package bd.com.escenic.flexilunch.model;

/**
 * $URL: http://flexilunch.googlecode.com/svn/trunk/common/src/main/java/bd/com/escenic/flexilunch/model/AbstractEntity.java $
 * $Id: AbstractEntity.java 14 2009-06-03 09:39:19Z shihab.uddin@gmail.com $
 * $Date: 2009-06-03 09:39:19 +0000 (Wed, 03 Jun 2009) $
 * $Author: shihab.uddin@gmail.com $
 * $Revision: 14 $
 */

import java.util.Date;

/**
 * $Id: AbstractEntity.java 14 2009-06-03 09:39:19Z shihab.uddin@gmail.com $.
 *
 * @author <a href="mailto:shihab.uddin@gmail.com">Shihab Uddin</a>
 * @version $Revision: 14 $
 */
abstract class AbstractEntity implements Entity {

  private int mId;
  private String mName;
  private String mDescription;
  private Date mDateCreated;
  private Date mDateUpdated;

  /**
   * {@inheritDoc}
   */
  @Override
  public int getId() {
    return mId;
  }

  /**
   * {@inheritDoc}
   */
  @Override
  public void setId(final int pId) {
    mId = pId;
  }

  /**
   * {@inheritDoc}
   */
  @Override
  public String getName() {
    return mName;
  }

  /**
   * {@inheritDoc}
   */
  @Override
  public void setName(final String pName) {
    mName = pName;
  }

  /**
   * {@inheritDoc}
   */
  @Override
  public String getDescription() {
    return mDescription;
  }

  /**
   * {@inheritDoc}
   */
  @Override
  public void setDescription(final String pDescription) {
    mDescription = pDescription;
  }

  /**
   * {@inheritDoc}
   */
  @Override
  public Date getDateCreated() {
    return mDateCreated;
  }

  /**
   * {@inheritDoc}
   */
  @Override
  public void setDateCreated(final Date pDateCreated) {
    mDateCreated = pDateCreated;
  }

  /**
   * {@inheritDoc}
   */
  @Override
  public Date getDateUpdated() {
    return mDateUpdated;
  }

  /**
   * {@inheritDoc}
   */
  @Override
  public void setDateUpdated(final Date pDateUpdated) {
    mDateUpdated = pDateUpdated;
  }

  /**
   * {@inheritDoc}
   */
  @Override
  public boolean equals(final Object pObject) {
    return this == pObject ||
        (pObject != null &&
            getClass().equals(pObject.getClass()) &&
            getId() == ((Entity) pObject).getId());
  }

  /**
   * {@inheritDoc}
   */
  @Override
  public int compareTo(final Entity pEntity) {
    return getId() - pEntity.getId();
  }

  /**
   * {@inheritDoc}
   */
  @Override
  public int hashCode() {
    return mId;
  }

  /**
   * {@inheritDoc}
   */
  @Override
  public String toString() {
    return getType().name() + "[id=" + getId() + "]";
  }
}
